var express = require('express');
var router = express.Router();
let { UserM, shop_list } = require('../../modules/long')

router.get('/user', async (req, res) => {
  let data = await UserM.find()
  res.send({
    code: 200,
    data
  })
})
router.get('/shop_list', async (req, res) => {
  let page = parseInt(req.query.page) || 1; // 默认为第1页
  let limit = parseInt(req.query.limit) || 4; // 默认为每页10条
  const skip = (page - 1) * limit;
  let data = await shop_list.find().skip(skip).limit(limit).exec()
  console.log(data);
  res.send({
    code: 200,
    data,
    totalPages: Math.ceil(data / limit),
    currentPage: page,
  })
})

router.get('/cate',async(req,res)=>{
  let data = await cate.find()
  res.send({
    code:200,
    data,
    ht:'http://127.0.0.1:3000/chen/cate'
  })
})
module.exports = router;

